package com.hkd.friend.controller.user;

import com.hkd.common.core.constants.HttpConstants;
import com.hkd.common.core.domain.R;
import com.hkd.friend.domain.user.dto.UserDTO;
import com.hkd.friend.service.user.IUserService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "用户端接口")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("/sendCode")
    public R sendCode(@RequestBody UserDTO userDTO){
        return userService.sendCode(userDTO);
    }

    @PostMapping("/code/login")
    public R codeLogin(@RequestBody UserDTO userDTO){
        return userService.codeLogin(userDTO);
    }

    @DeleteMapping("/logout")
    public R logout(@RequestHeader(HttpConstants.AUTHENTICATION) String token){
        return userService.logout(token);
    }

    @GetMapping("/info")
    public R getInfo(@RequestHeader(HttpConstants.AUTHENTICATION) String token){
        return userService.getInfo(token);
    }

}
